/**
 * create by young (young2f@outlook.com) on 2020/12/4
 * 采购物料批次占用关系表 缓存
 */
'use strict';
const model = require('../base/tModelBase');
const _ = require('lodash');
module.exports = app => {
  const mongoose = app.mongoose;
  const schema = mongoose.Schema;
  const connect = app.mongooseDB.get('pmcBus');
  const json = {
    recordId: { type: String, _type: 'string', title: '记录编码', required: true },
    procureOrderCode: { type: String, _type: 'string', title: '采购单编码', required: true },
    salesOrderCode: { type: String, _type: 'string', title: '订单编码', required: true },
    pmLotId: { type: String, _type: 'string', title: '物料批次编码', required: true },
    useCount: { type: Number, _type: 'number', title: '占用数量', required: true },
  };
  const _model = _.cloneDeep(model);
  _.assign(_model, json);
  const _schema = new schema(
    _model,
    { timestamps: { createdAt: 'createdTs', updatedAt: 'updatedTs' } }
  );
  return connect.model('CacheProcureLotUsed', _schema);
};
